/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.upc.clase.demo.dao.impl;

import edu.upc.clase.demo.dao.DistritoDao;
import edu.upc.clase.demo.dao.TipoPlatoDao;
import edu.upc.clase.demo.entity.TipoPlato;
import java.util.List;
import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.stereotype.Repository;

/**
 *
 * @author chavo
 */
@Repository //esto es una notacion que le dice al spring que es un objeto dato
public class TipoPlatoDaoImpl extends JdbcDaoSupport implements TipoPlatoDao{

    private static Logger log = LoggerFactory.getLogger(TipoPlatoDaoImpl.class);

    @Autowired //notacion que te permite inyectar un objeto delante de otro
    public TipoPlatoDaoImpl(DataSource datasource)
    {
        log.info("Asignando el dataSource");
        setDataSource(datasource);
    }
    
    @Override
    public Integer insertar(TipoPlato tipoPlato) {
        getJdbcTemplate().update(
                "insert into TipoPlato (DescripcionTipoPlato) values (?)",
                tipoPlato.getDescripcionTipoPlato());
        return getJdbcTemplate().queryForInt("select last_insert_id()"); //la ultima fila insertada
    }

    @Override
    public void actualizar(TipoPlato tipoPlato) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void eliminar(TipoPlato tipoPlato) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<TipoPlato> buscarTodos() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public TipoPlato buscar(Integer idPlato) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<TipoPlato> buscarPorNombre(String nombre) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    
}
